<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<title></title>
		<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/vant@2.5/lib/index.css">
		<link rel="stylesheet" href="../css/global.css">
		<link rel="stylesheet" href="../css/addressbook.css">
		<script src="../js/flexble.js"></script>
		<script src="https://cdn.jsdelivr.net/npm/vue@2.6.11"></script>
		<script src="https://cdn.jsdelivr.net/npm/vant@2.5/lib/vant.min.js"></script>
		<script type="text/javascript" src="../sdk/webimSDK3.1.2.js"></script>
		<script type="text/javascript" src="../js/WebIMConfig.js"></script>
		<script type="text/javascript" src="../js/webconn.js"></script>
		<script type="text/javascript" src="../js/localstorage.js"></script>
		<script type="text/javascript" src="../utils/msgtype.js"></script>
		<script type="text/javascript" src="../utils/login.js"></script>
		<style style="text/scss">
			.friendbox{
				padding-top: 1.2rem;
			}
		</style>
	</head>
	<body>
		<div id="bigbox" class="chatPageBox">
			<div class="fixedtop">
				<div class="getBack">
					<van-button class="arrowbox" type="default" @click="back">
						<img src="../img/back.png">
					</van-button>
					<!-- <p class="fixedtoptit">发起群聊</p>
					<van-button class="dingdan" type="primary" @click="opennamebox">
						确定({{chosenum}})
					</van-button> -->
				</div>
			</div>
			<div class="friendbox">
				<van-button 
				class="chatlistbox" 
				type="default" 
				@click="gourl('frienddetail.html',item)"
				v-for="(item,index) in groupList"
				:key="index"
				>
					<img class="avatar" src="../img/avatar.jpg">
					<div class="chatlist_rightbox">
						<div class="chatlistmidbox">
							<p class="chatname">{{item.name}}</p>
						</div>
					</div>
				</van-button>	
			</div>
		</div>
	</body>
</html>
<script type="text/javascript">
var webvue = new Vue({
	el: '#bigbox', 
	data() {
		return {
			groupList:[],
			groupid:''
		}
	},
	mounted(){
		isfirst = 4;
		relogin()
	},
	methods:{
		back(){
			window.location.href = 'addressbook.html';
		},
		gourl(url,item){
			saveStorage('pagedata',item)
			saveStorage('chatype','group')
			window.location.href = url;
		},
		getGroups(){ 
			var that = this;
			this.groupList = [];
			var options = {
			    success: function (resp) {
			        console.log("Response: ", resp)
					resp.data.forEach((item,index)=>{
						var obj = {
							groupid:item.groupid,
							sendID:item.groupid,
							name:item.groupname,
							// lastmsg:'最后一条消息',
							// time:'星期二'
						}
						that.groupList.push(obj)
					})
					console.log(that.groupList)
					// that.groupid = that.groupList[that.current_group].groupid;
					console.log(that.groupid)
			    },
			    error: function (e) {}
			}
			// setTimeout(()=>{
			// 	if(this.isgroup && that.current_group != -1){
			// 		that.yourname = that.groupList[that.current_group].name;
			// 	}else{
			// 		that.yourname = that.friendList[that.current].name;
			// 	}
			// },500)
			conn.getGroup(options);
		},
	}
})
</script>